<?php
/*
* index.job.php
* 
* Creado por udomos el 4 de diciembre del 2010.
* Última modificación por udomos el 4 de diciembre del 2010.
* Derechos Reservados a Udomos S.A. de C.V. 2010.
*/

// load config file
require_once ($_SERVER["DOCUMENT_ROOT"] . '/config/config.php');
// load date functions file
require_once ($_SERVER["DOCUMENT_ROOT"] . '/modules/functions/date_functions.php');

/*=====	BASE DE DATOS	=====*/

$mdb2 =& MDB2::connect($dsn, $opt);

if (PEAR::isError($mdb2))
	die('Could not connect: '. $mdb2->getMessage());
else{ 
	$WCAT = "";
	$WTYJ = "";
	$WGEN = "";
	$WSEA = "";
	$WDAT = "";
	$SAL = "";
	$ORDER = $OrderJobByQuery[$OBJobDateMax];
	
	if(isset($_POST['page'])) {
		$I = $_POST['page'];
		$I = ($I*$_TJL)-$_TJL;
	}
	
	else $I = 0;	
	$L = $_TJL;
	
	if(isset($_POST['job-search'])) {
	$jobSearch = strtolower($_POST['job-search']);
	$WSEA = "AND (LOWER(CONCAT(job_title,' ',job_description,' ',job_experience,' ',job_skills)) LIKE '%".$jobSearch."%')";
	}
	if(isset($_POST['job-cat'])) $WCAT = " AND(job_id_bazaar IN(".implode(",",$_POST['job-cat'])."))";
	if(isset($_POST['job-tyj'])) $WTYJ = " AND(job_id_jobType IN(".implode(",",$_POST['job-tyj'])."))";
	if(isset($_POST['job-gen'])) $WGEN = " AND(job_id_sex IN(".implode(",",$_POST['job-gen'])."))";
	if(isset($_POST['job-dat'])) {
		if($_POST['job-dat'] == 1) 		$WDAT = " AND(job_creationDate = CURDATE())";
		elseif($_POST['job-dat'] == 2) 	$WDAT = " AND(DATE_SUB(CURDATE(),INTERVAL $jobBoxArrNum1 DAY)<=job_creationDate)";
		elseif($_POST['job-dat'] == 3) 	$WDAT = " AND(DATE_SUB(CURDATE(),INTERVAL $jobBoxArrNum2 DAY)<=job_creationDate)";
		elseif($_POST['job-dat'] == 4) 	$WDAT = " AND(DATE_SUB(CURDATE(),INTERVAL $jobBoxArrNum3 DAY)<=job_creationDate)";
		elseif($_POST['job-dat'] == 5) 	$WDAT = " AND(DATE_SUB(CURDATE(),INTERVAL $jobBoxArrNum4 DAY)<=job_creationDate)";
		elseif($_POST['job-dat'] == 6) 	$WDAT = " AND(DATE_SUB(CURDATE(),INTERVAL $jobBoxArrNum5 DAY)<=job_creationDate)";
		elseif($_POST['job-dat'] == 7) 	$WDAT = " AND(DATE_SUB(CURDATE(),INTERVAL $jobBoxArrNum6 DAY)<=job_creationDate)";
		elseif($_POST['job-dat'] == 8) 	$WDAT = " AND(DATE_SUB(CURDATE(),INTERVAL $jobBoxArrNum7 DAY)<=job_creationDate)";
	}
	
	if(isset($_POST['job-ord'])){if($_POST['job-ord'] > 0) $ORDER = $OrderJobByQuery[$_POST['job-ord']];}

	$FROM = "FROM jobs 
			JOIN manager ON man_IDmanager = job_id_manager
			JOIN sucursalManager ON sm_id_manager = man_IDmanager
			JOIN sucursal ON suc_IDsucursal = sm_id_sucursal
			JOIN jobType ON jt_IDtype = job_id_jobType
			JOIN bazaarSubcategory ON bs_IDsubcategory = job_id_bazaar
			JOIN salaryType ON st_IDtype = job_id_salaryType
			JOIN currencyAd ON ca_IDcurrency = jod_id_currency 
			WHERE jod_id_status = $statusActive $WCAT $WGEN $WTYJ $WSEA $WDAT";
	
	$counter = _SF("SELECT COUNT(job_IDjob) AS counter $FROM","counter");
} 
	$counter = $counter/$_TJL;
	if(!is_int($counter)) $counter = ceil($counter);
	
	 
		 echo "<ul id='mycarousel' ";
		 if($counter >=15) echo "class='jcarousel-skin-tango'>"; else echo ">";
		 if($counter > 0){
			 for($i=1;$i<=$counter;$i++){	 
				echo "<li><span title='$i' class='";
				if($i == 1) echo "disabled-paginator"; else echo "enable-paginator";
				echo "'>$i</span></li>"; 	
			 }
		 }
		 echo "</ul>";
	 
	 
?>	
<script type="text/javascript">
	jQuery(document).ready(function() {
		jQuery('#mycarousel').jcarousel({
			wrap		:'both',
			visible		:15,
			scroll		:15,
		});
	});
</script>